import 'package:flutter/material.dart';
import '../model/main_view_model.dart';
import '../../../app_files.dart';
import 'main_pie_widget.dart';

class MainItemWidget {
  static Widget safeBuilder(
    BuildContext context,
    CommunityItemModel item, {
    bool showTask = false,
  }) {
    return Container(
      margin: EdgeInsets.only(left: 15, right: 15, bottom: 10),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(4)),
        color: Colors.white,
      ),
      padding: EdgeInsets.all(15),
      child: InkWell(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Text(
                  item.name,
                  style: TextThemeConfig.Font15WithBigColor22,
                ),
                Expanded(child: Container()),
                Text(
                  item.statusName,
                  style: TextThemeConfig.Font13WithColor99,
                )
              ],
            ),
            Padding(
              padding: EdgeInsets.only(top: 9, bottom: 4),
              child: Text(
                '地址：${item.address}',
                maxLines: 1,
                style: TextThemeConfig.Font14WithColor66,
              ),
            ),
            showTask
                ? Padding(
                    padding: EdgeInsets.only(bottom: 5),
                    child: Text(
                      '所属任务： ${item.planName}',
                      style: TextThemeConfig.Font14WithColor66,
                    ),
                  )
                : Container(),
            Row(
              children: [
                Indicator(
                  color: Color(0xff20E188),
                  text: '${item.checkNumber}户',
                  title: '已检',
                  padding: 5,
                  textStyle: TextThemeConfig.Font14WithColor22,
                ),
                Padding(
                  padding: EdgeInsets.only(left: 12),
                  child: Indicator(
                    color: Color(0xffdbdbdb),
                    text: '${item.unCheckNumber}户',
                    title: '待检',
                    padding: 5,
                    textStyle: TextThemeConfig.Font14WithColor22,
                  ),
                ),
              ],
            ),
            Padding(
              padding: EdgeInsets.only(top: 9),
              child: Row(
                children: [
                  Indicator(
                    color: Color(0xff6c99fa),
                    title: '正常',
                    text: '${item.normalNumber}户',
                    padding: 5,
                    textStyle: TextThemeConfig.Font14WithColor22,
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 8),
                    child: Indicator(
                      color: Color(0xffF97011),
                      text: '${item.fixNumber}户',
                      title: '自修',
                      padding: 5,
                      textStyle: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                ],
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 6),
              child: Row(
                children: [
                  Indicator(
                    color: Color(0xffFEC162),
                    padding: 5,
                    title: '隐患',
                    text: '${item.generalNumber}户',
                    textStyle: TextThemeConfig.Font14WithColor22,
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 8),
                    child: Indicator(
                      color: Color(0xffF2637B),
                      padding: 5,
                      title: '维修',
                      text: '${item.seriousNumber}户',
                      textStyle: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
        onTap: () {
          if (item.states == '4' || item.states == '5') {
            CommonUtils.showErrorInfo(context, '安检任务已关闭或中止');
          } else {
            CommonUtils.pushRoute(
              context,
              RoutePath.checkListView,
              arguments: {
                'itemID': item.itemID,
                'title': item.name,
                'planID': item.planID,
              },
            );
          }
        },
      ),
    );
  }

  static Widget patrolBuilder(
    BuildContext context,
    PatrolAreaModel item, {
    bool showTask = false,
  }) {
    Map<String, Color> colors = {
      '待巡检': Color.fromRGBO(108, 153, 250, 1),
      '巡检中': Color.fromRGBO(254, 193, 98, 1),
      '已完成': Color.fromRGBO(63, 206, 112, 1),
      '已中止': Colors.red,
      '已关闭': Colors.red,
      '未知': Colors.red,
    };

    return Container(
      margin: EdgeInsets.only(left: 15, right: 15, bottom: 10),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(4)),
        color: Colors.white,
      ),
      padding: EdgeInsets.all(15),
      child: InkWell(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Text(
                  item.areaName,
                  style: TextThemeConfig.Font15WithBigColor22,
                ),
                Expanded(child: Container()),
                Text(
                  item.statusName,
                  style: TextStyle(
                    color: colors[item.statusName],
                    fontSize: 13,
                    fontWeight: FontWeight.w500,
                  ),
                )
              ],
            ),
            showTask
                ? Padding(
                    padding: EdgeInsets.only(top: 5),
                    child: Text(
                      '所属任务： ${item.planName}',
                      style: TextThemeConfig.Font14WithColor66,
                    ),
                  )
                : Container(),
            Padding(
              padding: EdgeInsets.only(top: 6),
              child: Row(
                children: [
                  Indicator(
                    color: Color(0xff20E188),
                    text: '${item.checkedNum}',
                    title: '已检点数:',
                    padding: 6,
                    textStyle: TextThemeConfig.Font14WithColor22,
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 12),
                    child: Indicator(
                      color: Color(0xffdbdbdb),
                      text: '${item.needCheckNum}',
                      title: '待检点数:',
                      padding: 6,
                      textStyle: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                ],
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 9),
              child: Row(
                children: [
                  Indicator(
                    color: Color(0xff6c99fa),
                    padding: 5,
                    title: '正常点数:',
                    text: '${item.normalNumber}',
                    textStyle: TextThemeConfig.Font14WithColor22,
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 8),
                    child: Indicator(
                      color: Color(0xffF97011),
                      padding: 5,
                      title: '自修点数:',
                      text: '${item.fixNumber}',
                      textStyle: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                ],
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 6),
              child: Row(
                children: [
                  Indicator(
                    color: Color(0xffFEC162),
                    padding: 5,
                    title: '隐患点数:',
                    text: '${item.generalNumber}',
                    textStyle: TextThemeConfig.Font14WithColor22,
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 8),
                    child: Indicator(
                      color: Color(0xffF2637B),
                      padding: 5,
                      title: '维修点数:',
                      text: '${item.seriousNumber}',
                      textStyle: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                ],
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 9),
              child: Row(
                children: [
                  Text(
                    '巡检进度',
                    style: TextThemeConfig.Font14WithColor66,
                  ),
                  Expanded(
                    child: Container(
                      padding: EdgeInsets.symmetric(horizontal: 10),
                      child: MyProgressWidget(
                        value: item.checkRateValue,
                        color: Color(0xff20E188),
                      ),
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.only(right: 20),
                    child: Text(
                      '${item.checkRate}%',
                      style: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
        onTap: () {
          if (item.status == '4' || item.status == '5') {
            CommonUtils.showErrorInfo(context, '巡检任务已关闭或中止');
          } else {
            CommonUtils.pushRoute(
              context,
              RoutePath.patrolOrderListView,
              arguments: {
                'areaID': item.areaID,
                'title': item.areaName,
                'planID': item.planID,
              },
            );
          }
        },
      ),
    );
  }

  static Widget leaderBuilder(BuildContext context, LeaderItemModel item) {
    return Container(
      margin: EdgeInsets.only(left: 15, right: 15, bottom: 10),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(4)),
        color: Colors.white,
      ),
      padding: EdgeInsets.all(15),
      child: InkWell(
        child: Column(
          children: [
            Row(
              children: [
                ClipRRect(
                  borderRadius: BorderRadius.all(Radius.circular(20)),
                  child: CustomImage(
                    item.userHead,
                    width: 40,
                    height: 40,
                    fit: BoxFit.fill,
                    placeholderUrl: 'images/default_head.png',
                  ),
                ),
                Expanded(
                  child: Container(
                    padding: EdgeInsets.only(left: 15),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          item.userName,
                          style: TextThemeConfig.Font14WithColor22,
                        ),
                        Text(
                          item.phone,
                          style: TextThemeConfig.Font14WithColor66,
                        ),
                      ],
                    ),
                  ),
                ),
                InkWell(
                  child: Image.asset('images/bt_call.png'),
                  onTap: () => CommonUtils.callPhone(item.phone, context),
                )
              ],
            ),
            Padding(
              padding: EdgeInsets.only(top: 9),
              child: Row(
                children: [
                  Text(
                    item.type == 1 ? '管点总数' : '用户总数',
                    style: TextThemeConfig.Font14WithColor66,
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 4),
                    child: Text(
                      '${item.totalNumber}${item.type == 1 ? '个' : '户'}',
                      style: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 8),
                    child: Indicator(
                      color: Color(0xff20e188),
                      padding: 5,
                      title: '已检',
                      text:
                          '${item.checkedNumber}${item.type == 1 ? '个' : '户'}',
                      textStyle: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 8),
                    child: Indicator(
                      color: Color(0xffdbdbdb),
                      padding: 5,
                      title: '待检',
                      text:
                          '${item.unCheckNumber}${item.type == 1 ? '个' : '户'}',
                      textStyle: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                ],
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 9),
              child: Row(
                children: [
                  Indicator(
                    color: Color(0xff6c99fa),
                    title: '正常',
                    text: '${item.normalNumber}${item.type == 1 ? '个' : '户'}',
                    padding: 5,
                    textStyle: TextThemeConfig.Font14WithColor22,
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 8),
                    child: Indicator(
                      color: Color(0xffF97011),
                      text: '${item.fixNumber}${item.type == 1 ? '个' : '户'}',
                      title: '自修',
                      padding: 5,
                      textStyle: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                ],
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 6),
              child: Row(
                children: [
                  Indicator(
                    color: Color(0xffFEC162),
                    padding: 5,
                    title: '隐患',
                    text: '${item.generalNumber}${item.type == 1 ? '个' : '户'}',
                    textStyle: TextThemeConfig.Font14WithColor22,
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 8),
                    child: Indicator(
                      color: Color(0xffF2637B),
                      padding: 5,
                      title: '维修',
                      text:
                          '${item.seriousNumber}${item.type == 1 ? '个' : '户'}',
                      textStyle: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                ],
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 9),
              child: Row(
                children: [
                  Text(
                    '正常率',
                    style: TextThemeConfig.Font14WithColor66,
                  ),
                  Expanded(
                      child: Container(
                    padding: EdgeInsets.symmetric(horizontal: 10),
                    child: MyProgressWidget(
                      value: item.checkedNumber == 0
                          ? item.checkedNumber.toDouble()
                          : item.normalNumber / item.checkedNumber,
                      color: Color(0xff6c99fa),
                    ),
                  )),
                  Padding(
                    padding: EdgeInsets.only(right: 20),
                    child: Text(
                      item.commonScale,
                      style: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
        onTap: () => CommonUtils.pushRoute(
          context,
          RoutePath.communityListView,
          arguments: {'userID': item.userID, 'type': item.type},
        ),
      ),
    );
  }

  static Widget fixBuilder(BuildContext context, FixListItemModel item,
      {void onTap(_)}) {
    Widget _button() {
      if (item.status == '1') {
        return Row(
          children: [
            InkWell(
              child: Container(
                width: 60,
                height: 26,
                decoration: BoxDecoration(
                  color: ThemeConfig.mainColor,
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: Text(
                    '接单',
                    style: TextThemeConfig.Font12WithColorWhite,
                  ),
                ),
              ),
              onTap: () async {
                CommonUtils.showWaitLoading(context);
                ResultData res = await CommonNetWork.fixGetOrder(item.itemID);
                Navigator.pop(context);
                if (res.success) {
                  CommonUtils.showToast(context, '接单成功');
                  bus.emit('refreshList');
                } else {
                  CommonUtils.showErrorInfo(context, res.desc);
                }
              },
            ),
            Padding(padding: EdgeInsets.only(left: 15)),
            InkWell(
              child: Container(
                width: 60,
                height: 26,
                decoration: BoxDecoration(
                  border: Border.all(
                    color: ThemeConfig.mainColor,
                  ),
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: Text(
                    '转单',
                    style: TextThemeConfig.Font12WithMainColor,
                  ),
                ),
              ),
              onTap: () => CommonUtils.pushRoute(
                  context, RoutePath.orderTransferView,
                  arguments: {'itemID': item.itemID}),
            ),
          ],
        );
      }
      if (item.status == '2') {
        return Row(
          children: [
            InkWell(
              child: Container(
                width: 60,
                height: 26,
                decoration: BoxDecoration(
                  border: Border.all(
                    color: ThemeConfig.mainColor,
                  ),
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: Text(
                    '转单',
                    style: TextThemeConfig.Font12WithMainColor,
                  ),
                ),
              ),
              onTap: () => CommonUtils.pushRoute(
                  context, RoutePath.orderTransferView,
                  arguments: {'itemID': item.itemID}),
            ),
            Padding(padding: EdgeInsets.only(left: 15)),
            InkWell(
              child: Container(
                width: 90,
                height: 26,
                decoration: BoxDecoration(
                  border: Border.all(color: ThemeConfig.mainColor),
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Padding(
                        padding: EdgeInsets.only(top: 1),
                        child: Icon(
                          Icons.call,
                          color: ThemeConfig.mainColor,
                          size: 14,
                        ),
                      ),
                      Padding(
                        padding: EdgeInsets.only(left: 2, right: 4),
                        child: Text(
                          '联系他',
                          style: TextThemeConfig.Font12WithMainColor,
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              onTap: () => CommonUtils.callPhone(item.phone, context),
            ),
            Padding(padding: EdgeInsets.only(left: 15)),
            InkWell(
              child: Container(
                width: 90,
                height: 26,
                decoration: BoxDecoration(
                  color: ThemeConfig.mainColor,
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: Text(
                    '入户维修',
                    style: TextThemeConfig.Font12WithColorWhite,
                  ),
                ),
              ),
              onTap: () async {
                int res =
                    await CommonUtils.showOKCanceltView(context, '确定开始入户维修？');
                if (res == 1) {
                  CommonUtils.showWaitLoading(context);
                  ResultData res =
                      await CommonNetWork.fixRepairOrder(item.itemID);
                  Navigator.pop(context);
                  if (res.success) {
                    CommonUtils.showToast(context, '工单已为维修中状态');
                    bus.emit('refreshList');
                  } else {
                    CommonUtils.showErrorInfo(context, res.desc);
                  }
                }
              },
            ),
          ],
        );
      }
      if (item.status == '4') {
        return Row(
          children: [
            InkWell(
              child: Container(
                width: 90,
                height: 26,
                decoration: BoxDecoration(
                  border: Border.all(color: ThemeConfig.mainColor),
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Padding(
                        padding: EdgeInsets.only(top: 1),
                        child: Icon(
                          Icons.call,
                          color: ThemeConfig.mainColor,
                          size: 14,
                        ),
                      ),
                      Padding(
                        padding: EdgeInsets.only(left: 2, right: 4),
                        child: Text(
                          '联系他',
                          style: TextThemeConfig.Font12WithMainColor,
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              onTap: () => CommonUtils.callPhone(item.phone, context),
            ),
            Padding(padding: EdgeInsets.only(left: 15)),
            Container(
              width: 90,
              height: 26,
              decoration: BoxDecoration(
                color: ThemeConfig.mainColor,
                borderRadius: BorderRadius.all(Radius.circular(4)),
              ),
              child: Center(
                child: Text(
                  '开始维修',
                  style: TextThemeConfig.Font12WithColorWhite,
                ),
              ),
            ),
          ],
        );
      }
      return Text(
        '已完成维修',
        style: TextThemeConfig.Font14WithColor99,
      );
    }

    return Container(
      margin: EdgeInsets.only(left: 15, right: 15, top: 10),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(4)),
        color: Colors.white,
      ),
      padding: EdgeInsets.all(15),
      child: InkWell(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Padding(
              padding: EdgeInsets.only(bottom: 8),
              child: Text(
                item.title,
                style: TextThemeConfig.Font15WithColor22,
              ),
            ),
            Padding(
              padding: EdgeInsets.only(bottom: 8),
              child: Row(
                children: [
                  Expanded(
                    child: Text(
                      '类型：${item.itemTypeStr}',
                      style: TextThemeConfig.Font14WithColor22,
                    ),
                  ),
                  item.status != '5'
                      ? Container()
                      : Text(
                          item.itemResult,
                          style: item.result == '1'
                              ? TextThemeConfig.Font14WithMainColor
                              : TextThemeConfig.Font14WithColorRed,
                        )
                ],
              ),
            ),
            Row(
              children: [
                Text(
                  item.itemType == '5'
                      ? '管点名：${item.userName}'
                      : '姓名：${item.userName}',
                  style: TextThemeConfig.Font14WithColor99,
                ),
                Padding(padding: EdgeInsets.only(left: 24)),
                item.phone.isEmpty
                    ? Container()
                    : Text(
                        '电话：${item.phone}',
                        style: TextThemeConfig.Font14WithColor99,
                      ),
              ],
            ),
            Padding(
              padding: EdgeInsets.only(top: 8, bottom: 10),
              child: Text(
                '地址：${item.address}',
                style: TextThemeConfig.Font14WithColor99,
              ),
            ),
            Container(
              margin: EdgeInsets.only(bottom: 10),
              height: 1,
              width: double.infinity,
              color: ThemeConfig.separeColor,
            ),
            Row(
              children: [
                Expanded(child: Container()),
                _button(),
              ],
            ),
          ],
        ),
        onTap: () => onTap != null
            ? onTap(item)
            : item.status == '5'
                ? CommonUtils.pushRoute(context, RoutePath.fixResultView,
                    arguments: {
                        'isDetail': true,
                        'model': item,
                      })
                : CommonUtils.pushRoute(
                    context,
                    RoutePath.fixOrderView,
                    arguments: {'model': item},
                  ),
      ),
    );
  }

  static Widget engineerBuilder(BuildContext context, FixListItemModel item,
      {void onTap(_)}) {
    Widget _button() {
      if (item.status == '1') {
        return Row(
          children: [
            InkWell(
              child: Container(
                width: 90,
                height: 26,
                decoration: BoxDecoration(
                  border: Border.all(color: ThemeConfig.mainColor),
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Padding(
                        padding: EdgeInsets.only(top: 1),
                        child: Icon(
                          Icons.call,
                          color: ThemeConfig.mainColor,
                          size: 14,
                        ),
                      ),
                      Padding(
                        padding: EdgeInsets.only(left: 2, right: 4),
                        child: Text(
                          '联系他',
                          style: TextThemeConfig.Font12WithMainColor,
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              onTap: () => CommonUtils.callPhone(item.phone, context),
            ),
            Padding(padding: EdgeInsets.only(left: 15)),
            InkWell(
              child: Container(
                width: 60,
                height: 26,
                decoration: BoxDecoration(
                  color: ThemeConfig.mainColor,
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: Text(
                    '接单',
                    style: TextThemeConfig.Font12WithColorWhite,
                  ),
                ),
              ),
              onTap: () async {
                CommonUtils.showWaitLoading(context);
                ResultData res = await CommonNetWork.fixGetOrder(item.itemID);
                Navigator.pop(context);
                if (res.success) {
                  CommonUtils.showToast(context, '接单成功');
                  bus.emit('refreshList');
                } else {
                  CommonUtils.showErrorInfo(context, res.desc);
                }
              },
            ),
            Padding(padding: EdgeInsets.only(left: 15)),
            InkWell(
              child: Container(
                width: 60,
                height: 26,
                decoration: BoxDecoration(
                  border: Border.all(
                    color: ThemeConfig.mainColor,
                  ),
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: Text(
                    '转单',
                    style: TextThemeConfig.Font12WithMainColor,
                  ),
                ),
              ),
              onTap: () => CommonUtils.pushRoute(
                  context, RoutePath.orderTransferView,
                  arguments: {'itemID': item.itemID, 'isEngineer': true}),
            ),
          ],
        );
      }
      if (item.status == '2') {
        return Row(
          children: [
            InkWell(
              child: Container(
                width: 90,
                height: 26,
                decoration: BoxDecoration(
                  border: Border.all(color: ThemeConfig.mainColor),
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Padding(
                        padding: EdgeInsets.only(top: 1),
                        child: Icon(
                          Icons.call,
                          color: ThemeConfig.mainColor,
                          size: 14,
                        ),
                      ),
                      Padding(
                        padding: EdgeInsets.only(left: 2, right: 4),
                        child: Text(
                          '联系他',
                          style: TextThemeConfig.Font12WithMainColor,
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              onTap: () => CommonUtils.callPhone(item.phone, context),
            ),
            item.isAppointment != '1'
                ? Padding(
                    padding: EdgeInsets.only(left: 15),
                    child: InkWell(
                      child: Container(
                        width: 60,
                        height: 26,
                        decoration: BoxDecoration(
                          color: ThemeConfig.mainColor,
                          borderRadius: BorderRadius.all(Radius.circular(4)),
                        ),
                        child: Center(
                          child: Text(
                            '预约',
                            style: TextThemeConfig.Font12WithColorWhite,
                          ),
                        ),
                      ),
                      onTap: () async {
                        CommonUtils.showWaitLoading(context);
                        ResultData res =
                            await CommonNetWork.fixOrderAppoint(item.itemID);
                        Navigator.pop(context);
                        if (res.success) {
                          CommonUtils.showToast(context, '预约成功');
                          bus.emit('refreshList');
                        } else {
                          CommonUtils.showErrorInfo(context, res.desc);
                        }
                      },
                    ),
                  )
                : Container(),
            Padding(padding: EdgeInsets.only(left: 15)),
            Container(
              width: 90,
              height: 26,
              decoration: BoxDecoration(
                color: ThemeConfig.mainColor,
                borderRadius: BorderRadius.all(Radius.circular(4)),
              ),
              child: Center(
                child: Text(
                  '开始安装',
                  style: TextThemeConfig.Font12WithColorWhite,
                ),
              ),
            ),
            // InkWell(
            //   child: Container(
            //     width: 90,
            //     height: 26,
            //     decoration: BoxDecoration(
            //       color: ThemeConfig.mainColor,
            //       borderRadius: BorderRadius.all(Radius.circular(4)),
            //     ),
            //     child: Center(
            //       child: Text(
            //         '开始安装',
            //         style: TextThemeConfig.Font12WithColorWhite,
            //       ),
            //     ),
            //   ),
            //   onTap: () async {
            //     int res =
            //         await CommonUtils.showOKCanceltView(context, '确定开始安装？');
            //     if (res == 1) {
            //       CommonUtils.showWaitLoading(context);
            //       ResultData res =
            //           await CommonNetWork.fixRepairOrder(item.itemID);
            //       Navigator.pop(context);
            //       if (res.success) {
            //         CommonUtils.showToast(context, '工单已为安装中状态');
            //         bus.emit('refreshList');
            //       } else {
            //         CommonUtils.showErrorInfo(context, res.desc);
            //       }
            //     }
            //   },
            // ),
          ],
        );
      }
      if (item.status == '4') {
        return Row(
          children: [
            InkWell(
              child: Container(
                width: 90,
                height: 26,
                decoration: BoxDecoration(
                  border: Border.all(color: ThemeConfig.mainColor),
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Padding(
                        padding: EdgeInsets.only(top: 1),
                        child: Icon(
                          Icons.call,
                          color: ThemeConfig.mainColor,
                          size: 14,
                        ),
                      ),
                      Padding(
                        padding: EdgeInsets.only(left: 2, right: 4),
                        child: Text(
                          '联系他',
                          style: TextThemeConfig.Font12WithMainColor,
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              onTap: () => CommonUtils.callPhone(item.phone, context),
            ),
            Padding(padding: EdgeInsets.only(left: 15)),
            Container(
              width: 90,
              height: 26,
              decoration: BoxDecoration(
                color: ThemeConfig.mainColor,
                borderRadius: BorderRadius.all(Radius.circular(4)),
              ),
              child: Center(
                child: Text(
                  '开始安装',
                  style: TextThemeConfig.Font12WithColorWhite,
                ),
              ),
            ),
          ],
        );
      }
      return item.result == '1'
          ? Text(
              '已完成安装',
              style: TextThemeConfig.Font14WithColor99,
            )
          : Row(
              children: [
                InkWell(
                  child: Container(
                    width: 60,
                    height: 26,
                    decoration: BoxDecoration(
                      border: Border.all(
                        color: ThemeConfig.mainColor,
                      ),
                      borderRadius: BorderRadius.all(Radius.circular(4)),
                    ),
                    child: Center(
                      child: Text(
                        '转单',
                        style: TextThemeConfig.Font12WithMainColor,
                      ),
                    ),
                  ),
                  onTap: () => CommonUtils.pushRoute(
                      context, RoutePath.orderTransferView,
                      arguments: {'itemID': item.itemID, 'isEngineer': true}),
                ),
                MyInkWellWidget(
                  child: Container(
                    width: 90,
                    height: 26,
                    margin: EdgeInsets.only(left: 12),
                    decoration: BoxDecoration(
                      color: ThemeConfig.mainColor,
                      borderRadius: BorderRadius.all(Radius.circular(4)),
                    ),
                    child: Center(
                      child: Text(
                        '重新安装',
                        style: TextThemeConfig.Font12WithColorWhite,
                      ),
                    ),
                  ),
                  onTap: () async {
                    int ret = await CommonUtils.showOKCanceltView(
                        context, '是否重新开始订单?');
                    if (ret != 1) return;
                    CommonUtils.showWaitLoading(context);
                    ResultData res =
                        await CommonNetWork.engineerOrderReset(item.itemID);
                    Navigator.pop(context);
                    if (res.success) {
                      bus.emit('refreshList');
                    } else {
                      CommonUtils.showErrorInfo(context, res.desc);
                    }
                  },
                )
              ],
            );
    }

    void tapFuc() {
      if (item.status == '5') {
        if (GlobalStore.store.getState().userInfo.isCustomer) {
          CommonUtils.pushRoute(context, RoutePath.engineerGasResultView,
              arguments: {
                'isDetail': true,
                'info': item,
              });
        } else {
          CommonUtils.pushRoute(context, RoutePath.engineerResultView,
              arguments: {
                'isDetail': true,
                'model': item,
              });
        }
      } else {
        if (GlobalStore.store.getState().userInfo.isCustomer) {
          CommonUtils.pushRoute(context, RoutePath.engineerGasOpenView,
              arguments: {'model': item});
        } else {
          CommonUtils.pushRoute(context, RoutePath.engineerOrderView,
              arguments: {'model': item});
        }
      }
    }

    return Container(
      margin: EdgeInsets.only(left: 15, right: 15, top: 10),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(4)),
        color: Colors.white,
      ),
      padding: EdgeInsets.all(15),
      child: InkWell(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Padding(
                padding: EdgeInsets.only(bottom: 8),
                child: Text(
                  item.title,
                  style: TextThemeConfig.Font15WithColor22,
                ),
              ),
              Padding(
                padding: EdgeInsets.only(bottom: 8),
                child: Row(
                  children: [
                    Expanded(
                      child: Text(
                        '类型：${item.itemTypeStr}',
                        style: TextThemeConfig.Font14WithColor22,
                      ),
                    ),
                    item.status != '5'
                        ? item.status == '1'
                            ? Container()
                            : Text(
                                item.appointmentStr,
                                style: item.isAppointment == '1'
                                    ? TextThemeConfig.Font14WithMainColor
                                    : TextThemeConfig.Font14WithColorRed,
                              )
                        : Text(
                            item.itemResult,
                            style: item.result == '1'
                                ? TextThemeConfig.Font14WithMainColor
                                : TextThemeConfig.Font14WithColorRed,
                          )
                  ],
                ),
              ),
              Row(
                children: [
                  Text(
                    item.itemType == '5'
                        ? '管点名：${item.userName}'
                        : '姓名：${item.userName}',
                    style: TextThemeConfig.Font14WithColor99,
                  ),
                  Padding(padding: EdgeInsets.only(left: 24)),
                  item.phone.isEmpty
                      ? Container()
                      : Text(
                          '电话：${item.phone}',
                          style: TextThemeConfig.Font14WithColor99,
                        ),
                ],
              ),
              Padding(
                padding: EdgeInsets.only(top: 8, bottom: 4),
                child: Text(
                  '地址：${item.address}',
                  style: TextThemeConfig.Font14WithColor99,
                ),
              ),
              item.dispatchTime.isEmpty
                  ? Container()
                  : Padding(
                padding: EdgeInsets.only(bottom: 8),
                child: Text(
                  '派单时间：${item.dispatchTime}',
                  style: TextThemeConfig.Font14WithColor99,
                ),
              ),
              item.endTime.isEmpty
                  ? Container()
                  : Padding(
                      padding: EdgeInsets.only(bottom: 8),
                      child: Text(
                        '完成时间：${item.endTime}',
                        style: TextThemeConfig.Font14WithColor99,
                      ),
                    ),
              Container(
                margin: EdgeInsets.only(bottom: 10),
                height: 1,
                width: double.infinity,
                color: ThemeConfig.separeColor,
              ),
              Row(
                children: [
                  item.status == '9'
                      ? Text(
                          '隐患待排查',
                          style: TextThemeConfig.Font14WithColorRed,
                        )
                      : Container(),
                  Expanded(child: Container()),
                  _button(),
                ],
              ),
            ],
          ),
          onTap: () => onTap != null ? onTap(item) : tapFuc()),
    );
  }

  static Widget communityBuilder(
      BuildContext context, CheckListItemModel item) {
    Map<String, Color> colors = {
      '正常': Color.fromRGBO(108, 153, 250, 1),
      '隐患': Color.fromRGBO(254, 193, 98, 1),
      '维修': Color.fromRGBO(252, 117, 106, 1),
      '自修': Color.fromRGBO(252, 117, 106, 1),
    };

    Map<String, Color> doorColors = {
      '已入户': Color.fromRGBO(108, 153, 250, 1),
      '未入户': Color.fromRGBO(254, 193, 98, 1),
      '到访不遇': Color.fromRGBO(252, 117, 106, 1),
      '拒绝安检': Color.fromRGBO(252, 117, 106, 1),
    };

    setIndoorStatus() async {
      var res = await CommonUtils.showActionSheet(context,
          title: '确认入户', button: ['成功入户', '无法入户']);
      print(res);
      if (res != null) {
        if (res == 0) {
          int confirm = await CommonUtils.showOKCanceltView(context, '确认入户成功？');
          if (confirm == 1) {
            CommonUtils.showWaitLoading(context);
            ResultData res = await CommonNetWork.setIndoorStatus(
              item.orderID,
              userID: item.userID,
              status: '4',
              communityID: item.communityID,
            );
            Navigator.pop(context);
            if (res.success) {
              bus.emit('refreshList');
              CommonUtils.pushRoute(
                context,
                RoutePath.orderView,
                arguments: {'info': item},
              );
            } else {
              CommonUtils.showErrorInfo(context, res.desc);
            }
          }
        } else if (res == 1) {
          CommonUtils.pushRoute(context, RoutePath.refuseIndoorView,
              arguments: {'info': item});
        }
      }
    }

    delItem() async {
      int confirm = await CommonUtils.showOKCanceltView(context, '确认删除该条记录？');
      if (confirm == 1) {
        CommonUtils.showWaitLoading(context);
        ResultData res = await CommonNetWork.delCheckOrder(item.orderID);
        Navigator.pop(context);
        if (res.success) {
          bus.emit('refreshList');
        } else
          CommonUtils.showErrorInfo(context, res.desc);
      }
    }

    return Container(
      margin: EdgeInsets.only(left: 15, right: 15, top: 10),
      width: ScreenUtil.screenWidthDp,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(Radius.circular(4)),
      ),
      child: InkWell(
        child: Column(
          children: [
            Container(
              padding: EdgeInsets.all(15),
              child: Column(
                children: [
                  Row(
                    children: [
                      Text(
                        '客户名称：',
                        style: TextThemeConfig.Font14WithColor99,
                      ),
                      Text(
                        item.userName,
                        style: TextThemeConfig.Font14WithColor22,
                      ),
                    ],
                  ),
                  Padding(
                    padding: EdgeInsets.symmetric(vertical: 8),
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          '客户地址：',
                          style: TextThemeConfig.Font14WithColor99,
                        ),
                        Expanded(
                          child: Text(
                            item.userAddress,
                            maxLines: 1,
                            style: TextThemeConfig.Font14WithColor22,
                            overflow: TextOverflow.ellipsis,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Row(
                    children: [
                      Text(
                        '联系方式：',
                        style: TextThemeConfig.Font14WithColor99,
                      ),
                      Text(
                        item.phone,
                        style: TextThemeConfig.Font14WithColor22,
                      ),
                    ],
                  ),
                  Padding(
                    padding: EdgeInsets.only(top: 8),
                    child: Row(
                      children: [
                        Expanded(
                            child: Row(
                          children: [
                            Text(
                              '安检状态：',
                              style: TextThemeConfig.Font14WithColor99,
                            ),
                            Text(
                              item.checked ? '已检查' : '未检查',
                              style: TextThemeConfig.Font14WithColor22,
                            ),
                          ],
                        )),
                        Expanded(
                            child: item.checked
                                ? Row(
                                    children: [
                                      Text(
                                        '安全隐患：',
                                        style:
                                            TextThemeConfig.Font14WithColor99,
                                      ),
                                      Text(
                                        item.checkStatusStr,
                                        style: TextStyle(
                                          color: colors[item.checkStatusStr] ??
                                              Color(0xFF222222),
                                          fontSize: 14,
                                          fontWeight: FontWeight.w500,
                                        ),
                                      ),
                                    ],
                                  )
                                : Row(
                                    children: [
                                      Text(
                                        '入户状态：',
                                        style:
                                            TextThemeConfig.Font14WithColor99,
                                      ),
                                      Text(
                                        item.inDoorStatusStr,
                                        style: TextStyle(
                                          color: doorColors[
                                                  item.inDoorStatusStr] ??
                                              Color(0xFF222222),
                                          fontSize: 14,
                                          fontWeight: FontWeight.w500,
                                        ),
                                      ),
                                    ],
                                  ))
                      ],
                    ),
                  ),
                  item.checked
                      ? Padding(
                          padding: EdgeInsets.only(top: 8),
                          child: Row(
                            children: [
                              Text(
                                '安检时间：',
                                style: TextThemeConfig.Font14WithColor99,
                              ),
                              Text(
                                item.checkTime,
                                style: TextThemeConfig.Font14WithColor22,
                              ),
                            ],
                          ),
                        )
                      : Container(),
                ],
              ),
            ),
            Container(
              height: 50,
              padding: EdgeInsets.only(left: 15, right: 15),
              decoration: BoxDecoration(
                  border:
                      Border(top: BorderSide(color: ThemeConfig.separeColor))),
              child: Row(
                children: [
                  Expanded(child: Container()),
                  item.checked
                      ? Padding(
                          padding: EdgeInsets.only(right: 20),
                          child: InkWell(
                            child: Container(
                              width: 60,
                              height: 20,
                              decoration: BoxDecoration(
                                border: Border.all(color: Colors.red),
                                borderRadius:
                                    BorderRadius.all(Radius.circular(2)),
                              ),
                              child: MediaQuery(
                                //设置文字大小不随系统设置改变
                                data: MediaQuery.of(context)
                                    .copyWith(textScaleFactor: 1.0),
                                child: Center(
                                  child: Text(
                                    '删除记录',
                                    style: TextThemeConfig.Font12WithRedColor,
                                  ),
                                ),
                              ),
                            ),
                            onTap: () => delItem(),
                          ),
                        )
                      : Container(),
                  InkWell(
                    child: Image.asset('images/bt_call.png'),
                    onTap: () => CommonUtils.callPhone(item.phone, context),
                  ),
                  item.inDoorStatus != '4' &&
                          !GlobalStore.store.getState().userInfo.isCheckLeader
                      ? Padding(
                          padding: EdgeInsets.only(left: 20),
                          child: InkWell(
                            child: Container(
                              width: 60,
                              height: 20,
                              decoration: BoxDecoration(
                                border:
                                    Border.all(color: ThemeConfig.mainColor),
                                borderRadius:
                                    BorderRadius.all(Radius.circular(2)),
                              ),
                              child: MediaQuery(
                                //设置文字大小不随系统设置改变
                                data: MediaQuery.of(context)
                                    .copyWith(textScaleFactor: 1.0),
                                child: Center(
                                  child: Text(
                                    '确认入户',
                                    style: TextThemeConfig.Font12WithMainColor,
                                  ),
                                ),
                              ),
                            ),
                            onTap: () => setIndoorStatus(),
                          ),
                        )
                      : Container(),
                ],
              ),
            ),
          ],
        ),
        onTap: () => item.checked
            ? CommonUtils.pushRoute(context, RoutePath.orderResultView,
                arguments: {'info': item})
            : GlobalStore.store.getState().userInfo.isCheckLeader
                ? CommonUtils.showErrorInfo(context, '该客户未进行安检')
                : item.inDoorStatus == '4'
                    ? CommonUtils.pushRoute(
                        context,
                        RoutePath.orderView,
                        arguments: {'info': item},
                      )
                    : setIndoorStatus(),
//        onTap: () => CommonUtils.pushRoute(
//          context,
//          RoutePath.orderView,
//          arguments: {'info': item},
//        ),
      ),
    );
  }

  static Widget installItemBuilder(
      BuildContext context, InstallItemModel item) {
    return Container(
      margin: EdgeInsets.only(left: 15, right: 15, bottom: 10),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(Radius.circular(4)),
      ),
      padding: EdgeInsets.all(15),
      child: InkWell(
        child: Row(
          children: [
            Padding(
              padding: EdgeInsets.only(right: 15),
              child: Image.asset('images/icon_gas.png'),
            ),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    children: [
                      Text(
                        item.name,
                        style: TextThemeConfig.Font15WithColor22,
                      ),
                      Expanded(child: Container()),
                      Text(
                        '¥${item.money}',
                        style: TextThemeConfig.Font14WithMainColor,
                      )
                    ],
                  ),
                  Padding(padding: EdgeInsets.only(top: 6)),
                  Text(
                    '地址：${item.address}',
                    maxLines: 1,
                    style: TextThemeConfig.Font13WithColor99,
                  ),
                  Padding(padding: EdgeInsets.only(top: 2)),
                  Text(
                    '联系电话：${item.phone}',
                    maxLines: 1,
                    style: TextThemeConfig.Font13WithColor99,
                  ),
                ],
              ),
            ),
          ],
        ),
        onTap: () => CommonUtils.pushRoute(context, RoutePath.installView,
            arguments: {'itemID': item.itemID}),
      ),
    );
  }

  static Widget patrolItemBuilder(
      BuildContext context, PatrolOrderItemModel item) {
    Map<String, Color> colors = {
      '正常': Color.fromRGBO(108, 153, 250, 1),
      '隐患': Color.fromRGBO(254, 193, 98, 1),
      '维修': Color.fromRGBO(252, 117, 106, 1),
      '自修': Color.fromRGBO(252, 117, 106, 1),
    };

    Map<String, Color> doorColors = {
      '巡检中': Color.fromRGBO(108, 153, 250, 1),
      '待巡检': Color.fromRGBO(254, 193, 98, 1),
      '已完成': Color(0xff20e188),
      '无法巡检': Color.fromRGBO(252, 117, 106, 1),
    };

    setIndoorStatus() async {
      var res = await CommonUtils.showActionSheet(context,
          title: '开始巡检',
          button: item.pointStatus == '4' ? ['拍照签到'] : ['拍照签到', '无法巡检']);
      print(res);
      if (res != null) {
        if (res == 0) {
          CommonUtils.pushRoute(context, RoutePath.patrolSignInView,
              arguments: {'info': item});
        } else if (res == 1) {
          CommonUtils.pushRoute(context, RoutePath.patrolReasonView,
              arguments: {'info': item});
        }
      }
    }

    delItem() async {
      int confirm = await CommonUtils.showOKCanceltView(context, '确认删除该条记录？');
      if (confirm == 1) {
        CommonUtils.showWaitLoading(context);
        ResultData res = await CommonNetWork.delPatrolOrder(item.orderID);
        Navigator.pop(context);
        if (res.success) {
          bus.emit('refreshList');
        } else
          CommonUtils.showErrorInfo(context, res.desc);
      }
    }

    List<Widget> bottomItem() {
      List<Widget> items = [];
      items.add(Expanded(
        child: Container(),
      ));
      if (!GlobalStore.store.getState().userInfo.isPatrolWorker) return items;
      if (item.pointStatus == '1') {
        // items.add(Container(
        //   width: 78,
        //   height: 28,
        //   margin: EdgeInsets.only(right: 15),
        //   decoration: BoxDecoration(
        //     border: Border.all(color: Color(0xffFC6250)),
        //     borderRadius:
        //     BorderRadius.all(Radius.circular(2)),
        //   ),
        //   child: MediaQuery(
        //     //设置文字大小不随系统设置改变
        //     data: MediaQuery.of(context)
        //         .copyWith(textScaleFactor: 1.0),
        //     child: Center(
        //       child: Text(
        //         '无法巡检',
        //         style: TextStyle(
        //           color: Color(0xffFC6250),
        //           fontSize: 13,
        //           fontWeight: FontWeight.w600,
        //         ),
        //       ),
        //     ),
        //   ),
        // ));
        items.add(Container(
          width: 78,
          height: 28,
          decoration: BoxDecoration(
            color: ThemeConfig.mainColor,
            borderRadius: BorderRadius.all(Radius.circular(2)),
          ),
          child: MediaQuery(
            //设置文字大小不随系统设置改变
            data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
            child: Center(
              child: Text(
                '拍照签到',
                style: TextThemeConfig.Font13WithColorWhite,
              ),
            ),
          ),
        ));
      }
      if (item.pointStatus == '3') {
        items.add(MyInkWellWidget(
          child: Container(
            width: 78,
            height: 28,
            decoration: BoxDecoration(
              border: Border.all(color: Color(0xffFC6250)),
              borderRadius: BorderRadius.all(Radius.circular(2)),
            ),
            child: MediaQuery(
              //设置文字大小不随系统设置改变
              data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
              child: Center(
                child: Text(
                  '删除记录',
                  style: TextStyle(
                    color: Color(0xffFC6250),
                    fontSize: 13,
                    fontWeight: FontWeight.w600,
                  ),
                ),
              ),
            ),
          ),
          onTap: () => delItem(),
        ));
      }
      if (item.pointStatus == '2') {
        items.add(Container(
          width: 78,
          height: 28,
          decoration: BoxDecoration(
            color: ThemeConfig.mainColor,
            borderRadius: BorderRadius.all(Radius.circular(2)),
          ),
          child: MediaQuery(
            //设置文字大小不随系统设置改变
            data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
            child: Center(
              child: Text(
                '开始检查',
                style: TextThemeConfig.Font13WithColorWhite,
              ),
            ),
          ),
        ));
      }
      if (item.pointStatus == '4') {
        items.add(Container(
          width: 78,
          height: 28,
          decoration: BoxDecoration(
            color: ThemeConfig.mainColor,
            borderRadius: BorderRadius.all(Radius.circular(2)),
          ),
          child: MediaQuery(
            //设置文字大小不随系统设置改变
            data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
            child: Center(
              child: Text(
                '拍照签到',
                style: TextThemeConfig.Font13WithColorWhite,
              ),
            ),
          ),
        ));
      }
      return items;
    }

    return Container(
      margin: EdgeInsets.only(left: 15, right: 15, top: 10),
      width: ScreenUtil.screenWidthDp,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(Radius.circular(4)),
      ),
      child: InkWell(
        child: Column(
          children: [
            Container(
              padding: EdgeInsets.all(15),
              child: Column(
                children: [
                  Row(
                    children: [
                      Text(
                        '巡检工单编号：',
                        style: TextThemeConfig.Font14WithColor22,
                      ),
                      Text(
                        item.orderID,
                        style: TextThemeConfig.Font14WithColor22,
                      ),
                    ],
                  ),
                  Padding(
                    padding: EdgeInsets.only(top: 8),
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          '巡检状态：',
                          style: TextThemeConfig.Font14WithColor99,
                        ),
                        Text(
                          item.pointStatusStr,
                          style: TextStyle(
                            color: doorColors[item.pointStatusStr] ??
                                Color(0xFF222222),
                            fontSize: 14,
                            fontWeight: FontWeight.w500,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.only(top: 8),
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          '巡检地址：',
                          style: TextThemeConfig.Font14WithColor99,
                        ),
                        Expanded(
                          child: Text(
                            item.pointAddress,
                            style: TextThemeConfig.Font14WithMainColor,
                            overflow: TextOverflow.ellipsis,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.only(top: 8),
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          '管点编号：',
                          style: TextThemeConfig.Font14WithColor99,
                        ),
                        Text(
                          item.pointID,
                          style: TextThemeConfig.Font14WithColor22,
                        ),
                      ],
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.only(top: 8),
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          '管点名称：',
                          style: TextThemeConfig.Font14WithColor99,
                        ),
                        Text(
                          item.pointName,
                          style: TextThemeConfig.Font14WithColor22,
                        ),
                      ],
                    ),
                  ),
                  item.checked
                      ? Column(
                          children: [
                            Padding(
                              padding: EdgeInsets.only(top: 8),
                              child: Row(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Text(
                                    '巡检结果：',
                                    style: TextThemeConfig.Font14WithColor99,
                                  ),
                                  Text(
                                    item.checkStatusStr,
                                    style: TextStyle(
                                      color: colors[item.checkStatusStr] ??
                                          Color(0xFF222222),
                                      fontSize: 14,
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            Padding(
                              padding: EdgeInsets.only(top: 8),
                              child: Row(
                                children: [
                                  Text(
                                    '巡检时间：',
                                    style: TextThemeConfig.Font14WithColor99,
                                  ),
                                  Text(
                                    item.checkTime,
                                    style: TextThemeConfig.Font14WithColor22,
                                  ),
                                ],
                              ),
                            ),
                          ],
                        )
                      : Container(),
                  item.pointStatus == '4'
                      ? Container(
                          margin: EdgeInsets.only(top: 8),
                          width: double.infinity,
                          decoration: BoxDecoration(
                            color: Color(0xFFF5F6F9),
                            borderRadius: BorderRadius.all(Radius.circular(5)),
                          ),
                          padding:
                              EdgeInsets.symmetric(horizontal: 8, vertical: 8),
                          child: Text(
                            item.undoReason,
                            style: TextStyle(
                              color: Color(0xff777777),
                              fontSize: 13,
                              fontWeight: FontWeight.w500,
                            ),
                          ),
                        )
                      : Container(),
                ],
              ),
            ),
            bottomItem().length == 1
                ? Container()
                : Container(
                    height: 50,
                    padding: EdgeInsets.only(left: 15, right: 15),
                    decoration: BoxDecoration(
                        border: Border(
                            top: BorderSide(color: ThemeConfig.separeColor))),
                    child: Row(
                      children: bottomItem(),
                    ),
                  ),
          ],
        ),
        onTap: () => item.checked
            ? CommonUtils.pushRoute(context, RoutePath.patrolOrderResultView,
                arguments: {'info': item})
            : GlobalStore.store.getState().userInfo.isCheckLeader
                ? CommonUtils.showErrorInfo(context, '该管点未进行巡检')
                : item.pointStatus == '2'
                    ? CommonUtils.pushRoute(
                        context,
                        RoutePath.patrolOrderView,
                        arguments: {'info': item},
                      )
                    : setIndoorStatus(),
      ),
    );
  }
}
